//
//  MatchCell.m
//  Full_House
//
//  Created by 张忱 on 15-6-3.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "MatchCell.h"

@implementation MatchCell

- (void)dealloc{
    [_match release];
    [_photoImageView release];
    [_userImageView release];
    [_nameLabel release];
    [_starImageView release];
    [_numLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.photoImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_photoImageView];
        [_photoImageView release];
        
        self.userImageView = [[UIImageView alloc] init];
        [_photoImageView addSubview:_userImageView];
        [_userImageView release];
        
        self.nameLabel = [[UILabel alloc] init];
        [_photoImageView addSubview:_nameLabel];
        _nameLabel.backgroundColor = [UIColor clearColor];
        [_nameLabel release];
        
        self.starImageView = [[UIImageView alloc] init];
        [_photoImageView addSubview:_starImageView];
        [_starImageView release];
        
        self.numLabel = [[UILabel alloc] init];
        [_photoImageView addSubview:_numLabel];
        [_numLabel release];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    CGFloat width = self.contentView.bounds.size.width;
    CGFloat height = 400;
   
    self.photoImageView.frame = CGRectMake(0, 10, width ,height);
    
    self.userImageView.frame = CGRectMake(10, 400 - 50, 40, 40);
    _userImageView.layer.cornerRadius = 20;
    
    self.nameLabel.frame = CGRectMake(60, 400 - 30, 200, 10);
    
    self.starImageView.frame = CGRectMake(375 - 50, 400 - 30 - 10, 20, 20);
    self.starImageView.image = [UIImage imageNamed:@"iconfont-shoucang.png"];
    
    self.numLabel.frame = CGRectMake(375 - 50 + 15, 400 - 40, 10, 10);
    
    
}
- (void)setMatch:(Match *)match{
    
    if (_match != match) {
        [_match release];
        _match = [match retain];
    }
    
    
    NSURL *urlphoto = [NSURL URLWithString:self.match.image];
    [self.photoImageView setImageWithURL:urlphoto];
    
    NSURL *urluser = [NSURL URLWithString:self.match.userImage];
    [self.userImageView setImageWithURL:urluser];
    
    _nameLabel.text = self.match.userName;
    
    _numLabel.text = [NSString stringWithFormat:@"%ld", self.match.likeNum];


    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
